<template>
	<view v-if='codeUrl != ""'>
		<view style="background-color: #18b566;height:100vh;overflow: auto;">
			<view style='height:15vh'>

			</view>
			<view style='color:#fff;text-align: center;'>
				扫码核销
			</view>
			<view style='margin: 20px auto;width:270px;background-color: #fff;padding:10px;border-radius: 270px;'>
				<image :src='codeUrl' style='width:250px;height:250px;border-radius: 250px;padding:10px' />
			</view>
			<view v-if='order != ""' style='color:#fff;text-align: center;font-size:18px;padding:10px'>
				【{{order.no.slice(-8)}}】
			</view>
			<view style='color:#fff;font-size:14px;text-align: center;'>
				请到门店出示该核销码给门店店员进行扫码核销
			</view>
		</view>
	</view>
	<view v-else style='padding-top:30vh'>
		<u-empty mode="data" text='正在生成核销码'>
		</u-empty>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				codeUrl: '',
				order: ''
			}
		},
		onShow() {

		},
		onLoad(options) {
			if (typeof(options.id) != 'undefined') {
				const apiUrl = getApp().globalData.apiBase
				this.codeUrl = `${apiUrl}qr-code/mini-program?page=pages/orders/verify&scene=${options.id}`
				this.request.get(`api/orders/${options.id}`).then((res) => {
					this.order = res.data
				})
				console.log(this.codeUrl)
			} else {
				uni.showModal({
					title: '',
					content: '参数错误！',
					showCancel: false,
					success: () => {
						uni.switchTab({
							url: '/pages/orders/index'
						})
					}
				})
			}
		},

		methods: {}
	}
</script>

<style>
	.content {
		background-color: #f3f3f3;
		min-height: 100vh;
	}

	.group {
		margin: 10px;
		background-color: #fff;
		border-radius: 10px;
		padding: 10px;
	}

	.title {
		color: #909399;
		font-size: 14px;
		line-height: 32px;
	}

	.name {
		font-size: 14px;
		float: right;
		padding-right: 10px;
		line-height: 32px;
		color: #303133;
	}

	.date-btn {
		color: #f3f3f3;
		margin: 5px;
		background-color: #434152;
		border-radius: 5px;
		padding: 10px;
		text-align: center;
	}
</style>